package 学校work.test1201;

public class StringList {
    public static void printStringBufferTime() {
        StringBuffer stringBuffer = new StringBuffer();
        long prev = System.currentTimeMillis();
        for(int i = 0; i < 30_0000; i++) {
            stringBuffer.append("w");
        }
        long now = System.currentTimeMillis();
        System.out.println("StringBuffer变化30万次所需时间:" + (now - prev) + "ms");
    }
    public static void printStringTime() {
        String string = "";
        long prev = System.currentTimeMillis();
        for(int i = 0; i < 3_0000; i++) {
            string += "w";
        }
        long now = System.currentTimeMillis();
        System.out.println("String变化3万次所需时间:" + (now - prev) + "ms");
    }
    public static void main(String[] args) {
        printStringTime();
        printStringBufferTime();
    }
}
